package com.sunwayhorizo.health.common.delDataUtil;

import javax.ejb.Stateless;
import javax.persistence.Query;

import org.jboss.seam.annotations.JndiName;
import org.jboss.seam.annotations.Name;

import com.sunwayhorizo.health.business.base.BaseManager;
import com.sunwayhorizo.health.hl7.common.Hl7Exception;
import com.sunwayhorizo.health.hl7.rim.Act;

/**
 * @ClassName DelDataUtilManager <br>
 * @PackageName com.sunwayhorizo.health.common.delDataUtil <br>
 * @Description 删除数据库数据公共方法 <br>
 *              主要功能在于不用直接操作数据库来删除业务冗余数据<br>
 *              或者错误数据，在方便的操作是根据ControlAct Id来删除<br>
 *              关联到的数据。此方法可扩展，前提只接收一个aci ID，可扩展<br>
 *              接收多个参数
 * @Author jinzw <br>
 * @Date 2011-01-07 <br>
 * @Version 1.0 <br>
 * @ModifiedDesc <br>
 * @ModifiedDate <br>
 * @ModifiedBy <br>
 * @Email jinzw@sunwaysoft.com.cn <br>
 * @Copyright 2010-2020 北京三维海容 All Rights Reserved. <br>
 */

@Name("DelDataUtilManager")
@Stateless
public class DelDataUtilManager extends BaseManager implements DelDataUtilManagerLocal{
	
	 public void delAct(Long actid) throws Hl7Exception {
		 if(actid<0) return;
		 StringBuilder jbql = new StringBuilder();
			jbql.append("select act from Act act where act.actId=?1");
			Query query = em.createQuery(jbql.toString());
			query.setParameter(1, actid);
			Act act = (Act)query.getSingleResult();
			em.remove(act);
			log.info("删除关联到"+actid+"ControlAct的数据成功");
	}
}
